package com.zzyl.service.impl;


import com.zzyl.base.ResponseResult;
import com.zzyl.dto.FloorDto;
import com.zzyl.entity.Floor;
import com.zzyl.mapper.FloorMapper;
import com.zzyl.service.BedService;
import com.zzyl.service.FloorService;
import com.zzyl.service.RoomService;
import com.zzyl.vo.FloorVo;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;

import java.time.LocalDateTime;
import java.util.List;


@Service

public class FloorServiceImpl implements FloorService {


    @Autowired
    RoomService roomService;

    @Autowired
    BedService bedService;

    @Autowired
    private FloorMapper floorMapper;



    @Override
    public List<FloorVo> getAllWithRoomAndBed() {
        return floorMapper.selectAllRoomAndBed();
    }

    @Override
    public List<FloorVo> selectAllByNur() {
        return floorMapper.selectAllByNur();
    }
    //查询全部楼层
    @Override
    public List<FloorVo> selectFloor() {
        return    floorMapper.selectFloor();

    }
    //增加楼层
    @Override
    public void addFloor(FloorVo floorVo) {
        floorVo.setCreateTime(LocalDateTime.now());
        floorVo.setUpdateTime(LocalDateTime.now());
        floorVo.setCreateBy(1l);
        floorVo.setUpdateBy(1l);
        floorMapper.addFloor(floorVo);
    }
    //编辑回显
    @Override
    public FloorVo selectId(Integer id) {
        return   floorMapper.selectId(id);

    }
    //确实修改
    @Override
    public void update(FloorDto floorDto) {
        Floor floor = new Floor();
        BeanUtils.copyProperties(floorDto,floor);
        floor.setUpdateBy(1l);
        floor.setUpdateTime(LocalDateTime.now());
        FloorVo floorVo = new FloorVo();
        BeanUtils.copyProperties(floor,floorVo);
        floorMapper.update(floorVo);
    }
    //删除楼层
    @Override
    public void delete(Integer id) {
        floorMapper.delete(id);
    }

    //修改楼层   查询回显



}

